#include <iostream>
#include <cstdio>
#include <queue>
#include <utility>
#include <algorithm>

using namespace std; 

#define N 202

int a[N][N]; 
int f[N][N]; 
char m[N][N]; 
int row, col; 

int main()
{
	pair<int,int>p; 
	queue < pair<int,int> > q; 
	int res = -20000000; 
	int i, j, k;

	//freopen("p1508_1.in", "r", stdin); 

	cin>>row>>col; 
	for (i=1; i<=row; i++) {
		for (j=1; j<=col; j++) {
			cin>>a[i][j]; 
			f[i][j] = -20000000; 
		}
	}
	
	//printf("row=%d, col=%d\n", row, col); 
	
	q.push(make_pair(row+1, 1+col/2)); 
	while(!q.empty()) {
		p = q.front(); 
		q.pop(); 
		i = p.first-1; 
		if (i<1)
			continue; 
		for (k=-1; k<=1; k++) {
			j = p.second+k; 
			if (j<1 || j>col) 
				continue; 
			f[i][j] = max(f[i][j], f[p.first][p.second]+a[i][j]); 
			//printf("i=%d, j=%d, f=%d\n", i, j, f[i][j]); 
			if (m[i][j]==0) {
				q.push(make_pair(i, j)); 
				m[i][j] = 1; 
			}
		}
	}
	
	for (j=1; j<=col; j++) {
		res = max(res, f[1][j]); 
	}
	
	printf("%d\n", res); 
	
	return 0; 
}


